class Bank {
  balance: number[]
  constructor(balance: number[]) {
    this.balance = balance;
  }

  check(...accounts: number[]) {
      return accounts.every(e => e <= this.balance.length);
  }

  transfer(account1: number, account2: number, money: number): boolean {
    if(!this.check(account1, account2)) return false;
    if(this.balance[account1 - 1] < money) return false;
    this.balance[account2 - 1] += money;
    this.balance[account1 - 1] -= money;
    return true;
  }

  deposit(account: number, money: number): boolean {
    if(!this.check(account)) return false;
    this.balance[account - 1] += money;
    return true;
  }

  withdraw(account: number, money: number): boolean {
    if(!this.check(account)) return false;
    if(this.balance[account - 1] < money) return false;
    this.balance[account - 1] -= money;
    return true;
  }
}

/**
* Your Bank object will be instantiated and called as such:
* var obj = new Bank(balance)
* var param_1 = obj.transfer(account1,account2,money)
* var param_2 = obj.deposit(account,money)
* var param_3 = obj.withdraw(account,money)
*/